package site.zhangzhuo.learn_springboot.listener;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
public class UserRegistrationService {
    @Autowired
    private ApplicationContext applicationContext;

    public void registerUser(String username) {
        // 用户注册逻辑......

        // 用户注册成功，发布事件
        UserRegistrationEvent event = new UserRegistrationEvent(this, username);
        applicationContext.publishEvent(event);
    }
}
